class PurchaseSupplierLevel {
  String? id;
  String? levelName;
  String? levelRule;
  num? upper;
  num? lower;
  String? comment;
  String? createUid;
  String? createDate;
  String? templateId;

  PurchaseSupplierLevel({
    this.id,
    this.levelName,
    this.levelRule,
    this.upper,
    this.lower,
    this.comment,
    this.createUid,
    this.createDate,
    this.templateId,
  });

  PurchaseSupplierLevel copyWith({
    String? id,
    String? levelName,
    String? levelRule,
    String? upper,
    String? templateId,
  }) {
    return new PurchaseSupplierLevel(
      id: id ?? this.id,
      levelName: levelName ?? this.levelName,
      levelRule: levelRule ?? this.levelRule,
      templateId: templateId ?? this.templateId,
    );
  }

  @override
  String toString() {
    return '''PurchaseSupplierLevel{
      id: id,
      levelName: levelName,
      levelRule: levelRule,
      templateId: templateId,
    }''';
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      (other is PurchaseSupplierLevel &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          levelName == other.levelName &&
          levelRule == other.levelRule &&
          templateId == other.templateId);

  factory PurchaseSupplierLevel.fromMap(Map<String, dynamic> map) {
    return new PurchaseSupplierLevel(
      id: map['id'] != false ? map['id'].toString() as String? : "",
      levelName: map['level_name'] != false
          ? map['level_name'].toString() as String?
          : "",
      levelRule: map['level_rule'] != false
          ? map['level_rule'].toString() as String?
          : "",
      upper: map['upper'] != false ? map['upper'] : null,
      lower: map['lower'] != false ? map['lower'] : null,
      comment:
          map['comment'] != false ? map['comment'].toString() as String? : "",
      createUid: map['create_uid'] != false
          ? map['create_uid'][1].toString() as String?
          : "",
      createDate: map['create_date'] != false
          ? map['create_date'].toString() as String?
          : "",
      templateId: map['template_id'] != false
          ? map['template_id'][0].toString() as String?
          : "",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'levelName': this.levelName,
      'levelRule': this.levelRule,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if (this.levelName != null && this.levelName != '')
        ['level_name', 'like', '%${this.levelName}%'],
      if (this.templateId != null && this.templateId != '')
        ['template_id', '=', int.parse(this.templateId!)]
    ] as List;
    // if (list.length == 0) {
    //   list.add(['id', '!=', null]);
    // }
    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'template_id': int.parse(this.templateId!),
      'level_name': this.levelName,
      'level_rule': this.levelRule,
      'upper': this.upper,
      'lower': this.lower,
      'comment': this.comment,
    } as Map<String, dynamic>;
  }

//</editor-fold>

}
